/*
** client.h for my irc in /home/billey_b/projet/my_irc/my-irc-a
** 
** Made by Bastien Billey
** Login   <billey_b@epitech.net>
** 
** Started on  Tue Apr 17 11:27:14 2012 Bastien Billey
** Last update Tue Apr 17 11:28:23 2012 Bastien Billey
*/

#ifndef __CLIENT_H__
#define __CLIENT_H__

#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>

int			sock_client;

typedef struct		s_cmd
{
  char			*buff;
  char			*commande;
  char			*arg1;
  char			*arg2;
}			t_cmd;

typedef struct		s_client
{
  int			port;
  char			*ip;
  char			*name;
  struct sockaddr_in	addr;
  t_cmd			cmd;
}			t_client;

void	serveur(t_client *client);
void	nickname(t_client *client);
void	list(t_client *client);
void	join(t_client *client);
void	part(t_client *client);
void	users(t_client *client);
void	msg(t_client *client);
void	send_file(t_client *client);
void	accept_file(t_client *client);
void	help_cmd(t_client *client);
void	send_msg(t_client *client);
int	xsocket(int domain, int type, int protocol);
int	xbind(int sockfd, struct sockaddr *addr, socklen_t addrlen);
int	xconnect(int sockfd, struct sockaddr *addr, socklen_t addrlen);
int	xlisten(int sockfd, int backlog);
int	xaccept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
ssize_t	xread(int fd, void *buf, size_t count);
ssize_t	xwrite(int fd, const void *buf, size_t count);
int	xopen(const char *pathname, int flags);
void	*xmalloc(size_t size);
void	xfree(void *ptr);
int	xclose(int fd);
int	xselect(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
char	*parse_cmd(char *cmd);
void	parse_addr_and_port(t_client *client);
int	xsend(int sockfd, void *buf, size_t len, int flags);
int	xrecv(int sockfd, void *buf, size_t len, int flags);

#endif
